#include "processBar.h"
#include <unistd.h>
#include <string.h>

char buff[N];
const char sign[]="|/-\\";

void processBar(int rate)
{	
	if(rate<0 || rate>100)
		return;

	int len=strlen(sign);
	printf("[%-100s][%d%%][%c]\r",buff,rate,sign[rate%len]);
	fflush(stdout);
	buff[rate++]=CH;
	if(rate<100)
		buff[rate]='>';

	//usleep(50000);
	//printf("\n");
}

void init()
{
	memset(buff,0,N);
}
